<template>
  <div class="box">
    <!-- 头部 -->
    <div class="header">
      <van-icon name="arrow-left" @click="goBack" />
      <span>注册</span>
    </div>

    <div class="content">
      <div class="photo"> 
        <section><van-icon name="photo-fail" /></section>
        <section> 请设置验证码</section>
      </div>

      <van-cell-group :border="false">
        <van-field v-model="value" placeholder="请输入验证码" />
        <span class="value" @click="YZM">发送验证码</span>
      </van-cell-group>
      <van-button
        round
        type="info"
        color="linear-gradient(to right, #ff60349d, #ee0a2596)"
        @click="next"
        >下一步</van-button
      >

      <div class="msg">{{ msg }}</div>
    </div>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "captcha",
  data() {
    return {
      value: "",
      msg: "",
    };
  },
  methods: {
    goBack() {
      this.$router.back();
    }, 
    YZM(){
      axios({
        method: "post",
        url: "/api/user/dosendmsgcode",
        data:{
          tel:localStorage.getItem("tel")
        }
      }).then((res)=>{
        /* if(res.data.code == "200"){
          this.msg = `${res.data.message}:${res.data.data}`;
        } */
        console.log('YZM',res.data.data);
      })
    },
    next() {
      if (!this.value) {
        this.msg = "请填入内容";
        return;
      } else {
        axios({
          method: "post",
          url: "/api/user/docheckcode",
          data: {
            tel: localStorage.getItem("tel"),
            telcode: this.value,
          },
        }).then((res) => {
          if (res.data.code == "10007") {
            this.msg = "验证码错误";
            return;
          }
          if (res.data.code == "200") {
            this.$router.push("/Reg/pwd");
            // console.log("继续注册");
          }
        });
      }
    },
   
  },
};
</script>

<style scoped>
.header {
  height: 3.5rem;
  text-align: center;
  font-size: 1.3rem;
  line-height: 3.5rem;
  border-bottom: 2px solid gray;
}
.van-icon {
  float: left;
  padding-left: 10px;
  line-height: 3.5rem;
  color: rgb(24, 24, 64);
}
.content {
  margin: 3rem 1.5rem;
}
.van-button {
  margin: 1rem;
  width: 90%;
}
.value {
  height: 1.75rem;
  width: 5rem;
  text-align: center;
  border-radius: 0.5rem;
  line-height: 1.75rem;
  position: absolute;
  right:2.9167rem;
  top: 17.4rem;
  color: red;
  background-color: rgb(235, 178, 178);
  font-size: 0.6rem;
}

.photo{
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
} 
.photo section :nth-child(1){
    font-size: 30px;
    color: #efefef;
    margin:30px 0 40px;
}
.photo section :nth-child(2){
    font-size: 12px;
    margin-bottom: 30px;
}
</style>